/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sd.chat;

import java.io.Serializable;
import java.util.GregorianCalendar;
import java.util.Vector;

/**
 *
 * @author Old
 */
public class Message implements Serializable, Comparable {

    private Utilizador from;
    private Vector<Integer> to;
    private String text;
    private int id;
    private boolean wasread;
    private boolean haspic;
    private String pic;
    private GregorianCalendar data;

    public Message(Utilizador from, Vector<Integer> to, String text, int id, boolean wasread, boolean haspic, String pic, GregorianCalendar data) {
        this.from = from;
        this.to = to;
        this.text = text;
        this.id = id;
        this.wasread = wasread;
        this.haspic = haspic;
        this.pic = pic;
        this.data = data;
    }

    public Message(Utilizador from, Vector<Integer> to, String text) {
        this.from = from;
        this.to = to;
        this.text = text;
        this.id = -1;
        this.wasread = false;
        this.haspic = false;
        this.pic = "";
        this.data = new GregorianCalendar();
    }

    public GregorianCalendar getData() {
        return data;
    }

    public void setData(GregorianCalendar data) {
        this.data = data;
    }

    public Utilizador getFrom() {
        return from;
    }

    public void setFrom(Utilizador from) {
        this.from = from;
    }

    public boolean isHaspic() {
        return haspic;
    }

    public void setHaspic(boolean haspic) {
        this.haspic = haspic;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getPic() {
        return pic;
    }

    public void setPic(String pic) {
        this.pic = pic;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public Vector<Integer> getTo() {
        return to;
    }

    public void setTo(Vector<Integer> to) {
        this.to = to;
    }

    public boolean isWasread() {
        return wasread;
    }

    public void setWasread(boolean wasread) {
        this.wasread = wasread;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Message other = (Message) obj;
        if (this.id != other.id) {
            return false;
        }
        if (this.data != other.data && (this.data == null || !this.data.equals(other.data))) {
            return false;
        }
        return true;
    }

    
    @Override
    public String toString() {
        return "Message{" + "from=" + from + ", text=" + text + ", data=" + data + '}';
    }
    
    @Override
    public int compareTo(Object o) {
        return this.data.compareTo(((Message)o).getData());
    }
}
